package tuiLayer;

import java.util.Scanner;
/**
 * Write a description of class MainMenuUI here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class MainMenuUI
{
    // instance variables - replace the example below with your own
    private PersonUI personUI;
    private DVDUI dvdUI;
    private LoanUI loanUI;

    /**
     * Constructor for objects of class MainMenuUI
     */
    public MainMenuUI()
    {
        // initialise instance variables
        personUI = new PersonUI();
        dvdUI = new DVDUI();
        loanUI = new LoanUI();
        mainMenuStart();
        
    }
    
    private int getChoice()
    {
        Scanner keyboard = new Scanner(System.in);
        int choice = keyboard.nextInt();
        
        return choice;
    }
    

    public void mainMenuStart() 
    {
        boolean exit = false;
        
        while(!exit) 
        {
            writeMainMenu();
            int choice = getChoice();
            
            if(choice == 1) 
            {
                personUI.menuStart();
            }
            else if(choice == 2)
                {
                    dvdUI.menuStart();
                }
                else if(choice == 3)
                    {
                        loanUI.menuStart();
                    }
                    else if(choice == 4)
                        {
                            //writeClose();
                            exit = true;
                        }
                        
        }
    }
    
    private void writeMainMenu()
    {       
            // creates a keyboard object to read input
            System.out.println("\f *** Main Menu ***");
            System.out.println(" (1)Friends");
            System.out.println(" (2)DVDs");
            System.out.println(" (3)Loans");
            System.out.println(" (4)Close");
            System.out.print("\n Make your choice: ");
    }
    
    
    
}
